###########################################################
# $Id: xrsh_os.sh 4479 2012-12-22 13:04:08Z xrdk $
# brief	    : 
# author    : xrdk
# version   : V1.0, 2004-03-16
#
# CopyRight (C) 2004-2011 xrdk.
# All rights reserved.
###########################################################

function xrmk_os_get_ex()
{
	xrmk_os_get
	xrmk_os_ver_normal
	xrmk_os_ver_ex
	xrmk_os_ver_defs
	xrmk_os_dir_cvt
}

function xrmk_os_echo()
{
	echo ---------- OS info ------------------------
	echo OS: $xrmk_os_name $xrmk_os_vdot
	echo "--       version : $xrmk_os_vmaj $xrmk_os_vmin $xrmk_os_vnum"
	echo "--  version val. : $xrmk_os_vval"
	echo "--  version dash : $xrmk_os_vdash"
	echo "--    spec. name : $xrmk_os_specname"
	echo "-- spec. version : $xrmk_os_specver"
	echo "--         arch. : $xrmk_os_arch"
	echo "--   arch. is 64 : $xrmk_os_arch64"
  echo "--      dso ext. : $xrmk_dso_ext"
	echo "--      lib ext. : $xrmk_lib_ext"
	echo "--       defines : $xrmk_os_defs"
  echo --------------------------------------------
}

function xrmk_os_get()
{
	if [ "$xrmk_os_name" = "" ]; then xrmk_os_name="$xrmk_host_name" ; fi
	if [ "$xrmk_os_arch" = "" ]; then xrmk_os_arch="$xrmk_host_arch" ; fi
	
	if [ "$xrmk_os_vmaj" = "" ]; then xrmk_os_vmaj="$xrmk_host_vmaj" ; fi
	if [ "$xrmk_os_vmin" = "" ]; then xrmk_os_vmin="$xrmk_host_vmin" ; fi
	if [ "$xrmk_os_vnum" = "" ]; then xrmk_os_vnum="$xrmk_host_vnum" ; fi
	
	if [ "$xrmk_os_specname" = "" ]; then xrmk_os_specname="$xrmk_host_specname" ; fi
	if [ "$xrmk_os_specver" = "" ];  then xrmk_os_specver="$xrmk_host_specver" ; fi
	
	if [ "$xrmk_os_arch64" = "" ]; then xrmk_os_arch64=`xrsh_isarch64 $xrmk_os_arch`; fi
	
	if [ "$xrmk_dso_ext" = "" ]; then xrmk_dso_ext="$xrmk_host_dsoext" ; fi
	if [ "$xrmk_lib_ext" = "" ]; then xrmk_lib_ext="$xrmk_host_libext" ; fi
}

function xrmk_os_ver_normal()
{
	if [ "$xrmk_os_vmaj" = "" ] && [ "$xrmk_os_vmin" != "" ]; then xrmk_os_vmin= ; fi
	if [ "$xrmk_os_vmin" = "" ] && [ "$xrmk_os_vnum" != "" ]; then xrmk_os_vnum= ; fi
}

function xrmk_os_ver_ex()
{
	if [ "$xrmk_os_vmaj" = "" ]; then return; fi
	
	if [ "$xrmk_os_vdot" = "" ]; then
		xrmk_os_vdot="$xrmk_os_vmaj"
		if [ "$xrmk_os_vmin" != "" ]; then xrmk_os_vdot="$xrmk_os_vdot"."$xrmk_os_vmin" ; fi
		if [ "$xrmk_os_vnum" != "" ]; then xrmk_os_vdot="$xrmk_os_vdot"."$xrmk_os_vnum" ; fi
	fi

	if [ "$xrmk_os_vdash" = "" ]; then
		xrmk_os_vdash="$xrmk_os_vmaj"
		if [ "$xrmk_os_vmin" != "" ]; then xrmk_os_vdash="$xrmk_os_vdash"_"$xrmk_os_vmin" ; fi
	fi

	if [ "$xrmk_os_vval" = "" ]; then
		xrmk_os_vval="$xrmk_os_vmaj"
		if [ "$xrmk_os_vmin" != "" ]; then xrmk_os_vval="$xrmk_os_vval""$xrmk_os_vmin" ; fi
	fi
}

function xrmk_os_ver_defs()
{
	xrmk_os_defs="$xrmk_os_defs -D__xros_name=$xrmk_os_name"
	
	if test "$xrmk_os_vmaj" != ""; then xrmk_os_defs="$xrmk_os_defs -D__xros_vmaj=$xrmk_os_vmaj" ; fi
	if test "$xrmk_os_vmin" != ""; then	xrmk_os_defs="$xrmk_os_defs -D__xros_vmin=$xrmk_os_vmin" ; fi
	if test "$xrmk_os_vnum" != ""; then	xrmk_os_defs="$xrmk_os_defs -D__xros_vnum=$xrmk_os_vnum" ; fi

	if test "$xrmk_os_vval" = ""; then
	  xrmk_os_defs="$xrmk_os_defs -D__xros_$xrmk_os_name"
	else
		xrmk_os_defs="$xrmk_os_defs -D__xros_vval=$xrmk_os_vval"
	  xrmk_os_defs="$xrmk_os_defs -D__xros_$xrmk_os_name=$xrmk_os_vval"
	  xrmk_os_defs="$xrmk_os_defs -D__xros_$xrmk_os_name$xrmk_os_vval=$xrmk_os_vval"
	fi
}

function xrmk_os_dir_cvt()
{
	local _xrmk_tmp
	
	if [ "$xrmk_sinc" != "" ] && [ "$xrmk_sinc_i" = "" ]; then
		_xrmk_tmp=`echo ${xrmk_sinc[*]}`
		xrmk_sinc_i=`xrsh_itemcvt_inc "$_xrmk_tmp"`
	fi
	
	if [ "$xrmk_slib" != "" ] && [ "$xrmk_slib_l" = "" ]; then
		_xrmk_tmp=`echo ${xrmk_slib[*]}`
		xrmk_slib_l=`xrsh_itemcvt_lib "$_xrmk_tmp"`
	fi
}

